#include <X11/Xlib.h>

#include <stdio.h>
#include <err.h>

static Display* dpy;
static int scr;

static Window root;

// use xkill to select and kill this window
int main(void)
{
    Window win;
    XEvent ev;
    dpy = XOpenDisplay(NULL);

    if (dpy == NULL) {
        err(1, "ERROR: can not open display");
    }
    // get default screen and root window
    scr = XDefaultScreen(dpy);
    root = RootWindow(dpy, scr);
    // create our simple window
    win = XCreateSimpleWindow(dpy, root, 500, 500, 500, 500, 15, BlackPixel(dpy, scr), WhitePixel(dpy, scr));
    // map our window to display server
    XMapWindow(dpy, win);

    while (XNextEvent(dpy, &ev) == 0) {

    }

    // unmap our simple window
    XUnmapWindow(dpy, win);

    XDestroyWindow(dpy, win);
    XCloseDisplay(dpy);

    return 0;
}